package com.lhb.ojquestionservice.controller.inner;

import com.lhb.ojmodel.model.entity.Question;
import com.lhb.ojmodel.model.entity.QuestionSubmit;
import com.lhb.ojquestionservice.service.QuestionService;
import com.lhb.ojquestionservice.service.QuestionSubmitService;
import com.lhb.ojserviceclient.feignclient.QuestionFeignClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/inner")
public class QuestionInnerController implements QuestionFeignClient {
    @Resource
    private QuestionService questionService;

    @Resource
    private QuestionSubmitService questionSubmitService;

    /*
    * 得到题目信息
    * */
    @Override
    @GetMapping("/get/id")
    public Question getById(@RequestParam("questionId") Long questionId) {
        return questionService.getById(questionId);
    }

    /*
    * 获取题目提交信息
    * */
    @Override
    @GetMapping("/question_submit/get/id")
    public QuestionSubmit getQuestionSubmitById(@RequestParam("questionSubmitId") Long questionSubmitId) {
        return questionSubmitService.getById(questionSubmitId);
    }

    /*
    * 更新题目信息
    * */
    @Override
    @PostMapping("/question_submit/update")
    public boolean updateById(@RequestBody QuestionSubmit questionSubmit) {
        return questionSubmitService.updateById(questionSubmit);
    }
}
